package com.ptswitch.material.util;

import com.ptswitch.material.model.common.Uzer;

public class UserCheck {

    public static void mustAdmin(Uzer visitor) {
        if (visitor.getAdminGrade() != 0) {
            throw new AuthenticationException("请登录");
        }
    }

    public static void mustAdmins(Uzer visitor) {
        if (visitor.getAdminGrade() > 1) {
            throw new AuthenticationException("请登录");
        }
    }

    public static void mustLogin(Uzer visitor) {
        if ((visitor.getUsername().equals("guest"))) {
            throw new AuthenticationException("请登录");
        }
    }

    public static void mustSelf(Uzer visitor, Uzer user) {
        if (!visitor.getUsername().equals(user.getUsername())) {
            throw new AuthenticationException("请登录");
        }
    }
}
